import axios from 'axios'

console.log('读取环境变量设置', import.meta.env );

const BASE_URL = import.meta.env.MODE === "development" ? '/basice' : import.meta.env.VITE_BASIC_URL_API
// const BASE_URL = import.meta.env.VITE_BASIC_URL_API


const instance = axios.create({
  baseURL: BASE_URL, // api的BASE_URL
  timeout: 8000 // 请求超时时间
})

instance.interceptors.request.use(
  config => {
    return config
  },error => {
    // Do something with request error
    console.log(error) // for debug
    return Promise.reject(error)
  }
)


instance.interceptors.response.use(
  res => {
    return res
  },
  err => {
    return Promise.reject(err)
  }
)

export default {instance , BASE_URL}